import pandas as pd
df=pd.read_csv('../../file/分类信息.csv', encoding='utf_8_sig')
index=pd.read_csv('../../file/二级分类信息.csv', encoding='utf_8_sig')
df=df.iloc[:,0:3]
df=df.drop_duplicates()
df=pd.DataFrame(df)
data=[]
id=1
for row in df.iterrows():
    second_category=row[1]['second_category']
    matching_row=index[index['category']==second_category]
    s_id=matching_row['id'].values[0]
    f_id=matching_row['f_id'].values[0]
    category=row[1]['third_category']
    data.append({
        'id': id,
        'f_id': f_id,
        's_id': s_id,
        'category': category,
    })
    id=id+1

data=pd.DataFrame(data)
data.to_csv('三级分类信息.csv',index=False,encoding='utf_8_sig')